<?php
     include_once('classes/class.mssql.php');
     session_start();
     $comtec_id_machine = $_GET['id'];
   
    $db = new MSSQL();
    
    $texto = "SELECT m.comtec_id_owner,
		     m.comtec_id_configman,
		     m.tag_id_machine,
		     m.cod_mainteiner,
		     m.cod_owner,
                     m.brand,
		     m.model,            
                     m.year,
		     m.notes,
                     CONVERT(varchar,m.date_next_maintenance,103) AS date,
                     o.company_name,
                     (r.name+' '+r.lastname1+' '+r.lastname2) AS encargado,
                     c.configman_name
		     FROM ((machines as m INNER JOIN responsible as r ON m.comtec_id_responsible=r.comtec_id_responsible) INNER JOIN owner as o ON m.comtec_id_owner = o.comtec_id_owner) INNER JOIN 
                           configman as c ON c.comtec_id_configman = m.comtec_id_configman 
                     WHERE comtec_id_machine=".$comtec_id_machine;
    
    $result = $db->fetch_array($db->query($texto));  
   
    $comtec_id_owner=$result['comtec_id_owner'];
    $comtec_id_configman = $result['comtec_id_configman'];
    $encargado = $result['encargado'];
    $tag_id_machine = $result['tag_id_machine'];
    $cod_mainteiner = $result['cod_mainteiner'];
    $cod_owner = $result['cod_owner'];
    $brand  = $result['brand'];     
    $model = $result['model'];  
    $propietario = $result['company_name'];
    $configman = $result['configman_name'];  
    $year = $result['year'];
    $notes = $result['notes'];
    $date = $result['date'];
?>
<fieldset class="curved">
    <legend>Ver</legend>
			<table style="margin: 10px auto; border-spacing: 10px;">
			    <tr>
				<? if($_SESSION['users']!="clients"){ ?>
                                <td width="200"><label>Tag Id.</label></td>
				<td><input type="text" DISABLED size="40" value="<?=$tag_id_machine;?>"/></td>
				<? }?>
                                <td width="200"><label>Marca</label></td>
				<td><input type="text" DISABLED size="40" value="<?=$brand;?>"/></td>
			    </tr>
			    <tr>
                                <td width="200"><label>Cod. mantenedor</label></td>
				<td><input type="text" DISABLED size="40" value="<?=$cod_mainteiner;?>"/></td>
                                <td width="200"><label>Modelo</label></td>
				<td><input type="text" DISABLED size="40" value="<?=$model;?>"/></td>
			    </tr>
			    <tr>
				<td width="200"><label>A&ntilde;o</label></td>
				<td><input type="text" DISABLED size="40" value="<?=$year;?>"/></td>
                                <td width="200"><label>Encargado</label></td>
                                <td><input type="text" DISABLED size="40" value="<?=$encargado;?>"/></td>
			    </tr>
			    <tr>
                                <td width="200"><label>Propietario</label></td>  
				<td><input type="text" DISABLED size="40" value="<?=$propietario?>"/>                                 
				</td>

                                <td width="200"><label>Configuraci&oacute;n</label></td>
				<td><input type="text" DISABLED size="40" value="<?=$configman?>"/>
				</td>
				
			    </tr>
			    <tr>
                                <td width="200"><label>C&oacute;d. propietario</label></td>
				<td><input type="text" DISABLED size="40" value="<?=$cod_owner;?>"/></td>
			    </tr>
                            <tr>
                                <td width="200"><label>Fecha pr&oacute;x. mant.</label></td>
                                <td><input type="text" DISABLED size="40" value="<?=$date;?>"/></td>
                            </tr>
                            <tr>
                                <td width="200"><label>Notas</label></td>
				<td colspan="4"><textarea rows="2" cols="91" readonly="readonly" style="resize:none"><?=$notes;?></textarea></td>
			    </tr>
                            <tr><td><input type="button" value="Regresar" id="send" onclick='javascript:loadHome()' /></td></tr>
			</table>                  
		    </fieldset>